if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_getImportExportBillByID]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_getImportExportBillByID]
GO
CREATE PROC sp_getImportExportBillByID
	@id		int
AS
BEGIN
	SELECT A.ID, A.CustomerID, A.Date, A.Status, A.ApprovedByUser, A.TotalPrice, A.Discount, A.LastUpdate, A.Type, A.RejectReason, A.OrderID,
		(B.FirstName + ' ' + B.LastName) As CusName, (C.FirstName + ' ' + C.LastName) As ApprovedName
		FROM ImportExportBills As A
			LEFT JOIN AccountInformation As B ON A.CustomerID = B.AccountID
			LEFT JOIN AccountInformation As C ON A.ApprovedByUser = B.AccountID
		WHERE A.ID = @id
		ORDER BY A.Date DESC
END